from typing import TypedDict
from enum import Enum
from soj.builtin.environ.workspace import WorkSpace
from pathlib import Path
def is_file(path:Path):
    return path.is_file() and path.exists()

def ensure_file(path:Path):
    if not is_file(path):
        raise FileNotFoundError(f"File {path.resolve()} does not exist.")
from soj.settings.compile.common import MAX_COMPLIE_MSG
def translate_msg(msg:str):
    if len(msg)==0:
        return "No further infomation from compiler."
    return msg[:MAX_COMPLIE_MSG]+"..." if len(msg)>MAX_COMPLIE_MSG else msg

class CompileResult(TypedDict):
    ok:bool
    msg:str|None=None
    output:WorkSpace
    artifact:Path
